package com.zy.demo018081.controller;

import com.zy.demo018081.pojo.po.DepartPo;
import com.zy.demo018081.service.DepartService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/depart")
public class DepartController {

    private final DepartService departService;

    @PostMapping("/")
    public boolean save(@RequestBody DepartPo po) {
        return departService.save(po);
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Long id) {
        return departService.deleteById(id);
    }

    @PutMapping("/")
    public boolean modify(@RequestBody DepartPo po) {
        return departService.modify(po);
    }

    @GetMapping("/{id}")
    public DepartPo getById(@PathVariable Long id) {
        return departService.getById(id);
    }

    @GetMapping("/list")
    public List<DepartPo> getAll() {
        return departService.getAll();
    }
}
